package com.numbfish.ch01_ex03_bean_processor.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Slf4j
@Data
public class Person implements InitializingBean, DisposableBean {
    private String name;
    private Integer age;

    public Person(String name, Integer age)  {
        log.info("第1步: Person 全参构造器被调用了...");
        this.name = name;
        this.age = age;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        log.info("第4步 属性赋值完成后Person afterPropertiesSet 被调用了...");
    }

    @PostConstruct
    public void postConstruct() {
        log.info("第3步 Person postConstruct 被调用了...");
    }

    @PreDestroy
    public void preDestroy() {
        log.info("第6步: Person preDestroy 被调用了...");
    }

    @Override
    public void destroy() throws Exception {
        log.info("第7步:Person DisposableBean 被调用了...");
    }


}
